// -*- C++ -*-
/*!
 * @file  ${rtcParam.name}.h
 * @brief ${rtcParam.description}
 * @date  ${dol}Date${dol}
#parse("${template}/cpp/_doc.vsl")
 * ${dol}Id${dol}
 */

${sharp}ifndef ${rtcParam.name.toUpperCase()}_H
${sharp}define ${rtcParam.name.toUpperCase()}_H

${sharp}include <rtm/idl/BasicDataTypeSkel.h>
${sharp}include <rtm/idl/ExtendedDataTypesSkel.h>
${sharp}include <rtm/idl/InterfaceDataTypesSkel.h>

// Service implementation headers
// <rtc-template block="service_impl_h">
#foreach($providerIdlFile in ${rtcParam.providerIdlPathes})
${sharp}include "${tmpltHelper.getFilenameNoExt(${providerIdlFile.idlFile})}${tmpltHelper.serviceImplSuffix}.h"
#end

// </rtc-template>

// Service Consumer stub headers
// <rtc-template block="consumer_stub_h">
#foreach($consumerIdlFile in ${rtcParam.consumerIdlPathes})
${sharp}include "${tmpltHelper.getFilenameNoExt(${consumerIdlFile.idlFile})}${tmpltHelper.serviceStubSuffix}.h"
#end

// </rtc-template>

${sharp}include <rtm/Manager.h>
${sharp}include <rtm/${rtcParam.componentKind}Base.h>
${sharp}include <rtm/CorbaPort.h>
${sharp}include <rtm/DataInPort.h>
${sharp}include <rtm/DataOutPort.h>
#if( ${tmpltHelper.checkFSM(${rtcParam})} )

// FSM headers

#if( ${tmpltHelper.checkFSM(${rtcParam})})${sharp}include <rtm/EventPort.h>#end

// <rtc-template block="fsm_h">
${sharp}include "${rtcParam.name}FSM.h"
// </rtc-template>
#end


/*!
 * @class ${rtcParam.name}
 * @brief ${rtcParam.description}
#if( ${rtcParam.docDescription.length()} > 0 )
 *
 * ${tmpltHelper.convertDoc(${rtcParam.docDescription})}
#end
#if( ${rtcParam.docInOut.length()} > 0 )
 *
 * ${tmpltHelper.convertDoc(${rtcParam.docInOut})}
#end
#if( ${rtcParam.docAlgorithm.length()} > 0 )
 *
 * ${tmpltHelper.convertDoc(${rtcParam.docAlgorithm})}
#end
#if( ${rtcParam.docReference.length()} > 0 )
 *
 * ${tmpltHelper.convertDoc(${rtcParam.docReference})}
#end
 *
 */
class ${rtcParam.name}
  : public RTC::${rtcParam.componentKind}Base
{
 public:
  /*!
   * @brief constructor
   * @param manager Maneger Object
   */
  ${rtcParam.name}(RTC::Manager* manager);

  /*!
   * @brief destructor
   */
  ~${rtcParam.name}() override;

  // <rtc-template block="public_attribute">
#foreach($publicAttribute in ${rtcParam.publicAttributes})
  ${publicAttribute}
#end
  
  // </rtc-template>

  // <rtc-template block="public_operation">
#foreach($publicOperation in ${rtcParam.publicOperations})
  ${publicOperation}
#end
  
  // </rtc-template>

  // <rtc-template block="activity">
  /***
#if(${rtcParam.getDocActionOverView(0).length()}>0)   * ${tmpltHelper.convertDescDoc(${rtcParam.getDocActionOverView(0)})}
#end
   *
   * The initialize action (on CREATED->ALIVE transition)
   *
   * @return RTC::ReturnCode_t
   * 
#if(${rtcParam.getDocActionPreCondition(0).length()}>0)   * @pre ${tmpltHelper.convertPreDoc(${rtcParam.getDocActionPreCondition(0)})}
#end
#if(${rtcParam.getDocActionPostCondition(0).length()}>0)   * @post ${tmpltHelper.convertPostDoc(${rtcParam.getDocActionPostCondition(0)})}
#end
   * 
   */
  #if(${rtcParam.configParams.size()}==0 && ${rtcParam.IsNotImplemented(0)} && ${rtcParam.inports.size()}==0 && ${rtcParam.outports.size()}==0 && ${rtcParam.servicePorts.size()}==0)//#end RTC::ReturnCode_t onInitialize() override;

  /***
#if(${rtcParam.getDocActionOverView(0).length()}>0)   * ${tmpltHelper.convertDescDoc(${rtcParam.getDocActionOverView(1)})}
#end
   *
   * The finalize action (on ALIVE->END transition)
   *
   * @return RTC::ReturnCode_t
   * 
#if(${rtcParam.getDocActionPreCondition(1).length()}>0)   * @pre ${tmpltHelper.convertPreDoc(${rtcParam.getDocActionPreCondition(1)})}
#end
#if(${rtcParam.getDocActionPostCondition(1).length()}>0)   * @post ${tmpltHelper.convertPostDoc(${rtcParam.getDocActionPostCondition(1)})}
#end
   * 
   */
  #if(${rtcParam.IsNotImplemented(1)})//#end RTC::ReturnCode_t onFinalize() override;

  /***
#if(${rtcParam.getDocActionOverView(2).length()}>0)   * ${tmpltHelper.convertDescDoc(${rtcParam.getDocActionOverView(2)})}
#end
   *
   * The startup action when ExecutionContext startup
   *
   * @param ec_id target ExecutionContext Id
   *
   * @return RTC::ReturnCode_t
   * 
#if(${rtcParam.getDocActionPreCondition(2).length()}>0)   * @pre ${tmpltHelper.convertPreDoc(${rtcParam.getDocActionPreCondition(2)})}
#end
#if(${rtcParam.getDocActionPostCondition(2).length()}>0)   * @post ${tmpltHelper.convertPostDoc(${rtcParam.getDocActionPostCondition(2)})}
#end
   * 
   */
  #if(${rtcParam.IsNotImplemented(2)})//#end RTC::ReturnCode_t onStartup(RTC::UniqueId ec_id) override;

  /***
#if(${rtcParam.getDocActionOverView(3).length()}>0)   * ${tmpltHelper.convertDescDoc(${rtcParam.getDocActionOverView(3)})}
#end
   *
   * The shutdown action when ExecutionContext stop
   *
   * @param ec_id target ExecutionContext Id
   *
   * @return RTC::ReturnCode_t
   * 
#if(${rtcParam.getDocActionPreCondition(3).length()}>0)   * @pre ${tmpltHelper.convertPreDoc(${rtcParam.getDocActionPreCondition(3)})}
#end
#if(${rtcParam.getDocActionPostCondition(3).length()}>0)   * @post ${tmpltHelper.convertPostDoc(${rtcParam.getDocActionPostCondition(3)})}
#end
   * 
   */
  #if(${rtcParam.IsNotImplemented(3)})//#end RTC::ReturnCode_t onShutdown(RTC::UniqueId ec_id) override;

  /***
#if(${rtcParam.getDocActionOverView(4).length()}>0)   * ${tmpltHelper.convertDescDoc(${rtcParam.getDocActionOverView(4)})}
#end
   *
   * The activated action (Active state entry action)
   *
   * @param ec_id target ExecutionContext Id
   *
   * @return RTC::ReturnCode_t
   * 
#if(${rtcParam.getDocActionPreCondition(4).length()}>0)   * @pre ${tmpltHelper.convertPreDoc(${rtcParam.getDocActionPreCondition(4)})}
#end
#if(${rtcParam.getDocActionPostCondition(4).length()}>0)   * @post ${tmpltHelper.convertPostDoc(${rtcParam.getDocActionPostCondition(4)})}
#end
   * 
   */
  #if(${rtcParam.IsNotImplemented(4)})//#end RTC::ReturnCode_t onActivated(RTC::UniqueId ec_id) override;

  /***
#if(${rtcParam.getDocActionOverView(5).length()}>0)   * ${tmpltHelper.convertDescDoc(${rtcParam.getDocActionOverView(5)})}
#end
   *
   * The deactivated action (Active state exit action)
   *
   * @param ec_id target ExecutionContext Id
   *
   * @return RTC::ReturnCode_t
   * 
#if(${rtcParam.getDocActionPreCondition(5).length()}>0)   * @pre ${tmpltHelper.convertPreDoc(${rtcParam.getDocActionPreCondition(5)})}
#end
#if(${rtcParam.getDocActionPostCondition(5).length()}>0)   * @post ${tmpltHelper.convertPostDoc(${rtcParam.getDocActionPostCondition(5)})}
#end
   * 
   */
  #if(${rtcParam.IsNotImplemented(5)})//#end RTC::ReturnCode_t onDeactivated(RTC::UniqueId ec_id) override;

  /***
#if(${rtcParam.getDocActionOverView(9).length()}>0)   * ${tmpltHelper.convertDescDoc(${rtcParam.getDocActionOverView(9)})}
#end
   *
   * The execution action that is invoked periodically
   *
   * @param ec_id target ExecutionContext Id
   *
   * @return RTC::ReturnCode_t
   * 
#if(${rtcParam.getDocActionPreCondition(9).length()}>0)   * @pre ${tmpltHelper.convertPreDoc(${rtcParam.getDocActionPreCondition(9)})}
#end
#if(${rtcParam.getDocActionPostCondition(9).length()}>0)   * @post ${tmpltHelper.convertPostDoc(${rtcParam.getDocActionPostCondition(9)})}
#end
   * 
   */
  #if(${rtcParam.IsNotImplemented(9)})//#end RTC::ReturnCode_t onExecute(RTC::UniqueId ec_id) override;

  /***
#if(${rtcParam.getDocActionOverView(6).length()}>0)   * ${tmpltHelper.convertDescDoc(${rtcParam.getDocActionOverView(6)})}
#end
   *
   * The aborting action when main logic error occurred.
   *
   * @param ec_id target ExecutionContext Id
   *
   * @return RTC::ReturnCode_t
   * 
#if(${rtcParam.getDocActionPreCondition(6).length()}>0)   * @pre ${tmpltHelper.convertPreDoc(${rtcParam.getDocActionPreCondition(6)})}
#end
#if(${rtcParam.getDocActionPostCondition(6).length()}>0)   * @post ${tmpltHelper.convertPostDoc(${rtcParam.getDocActionPostCondition(6)})}
#end
   * 
   */
  #if(${rtcParam.IsNotImplemented(6)})//#end RTC::ReturnCode_t onAborting(RTC::UniqueId ec_id) override;

  /***
#if(${rtcParam.getDocActionOverView(7).length()}>0)   * ${tmpltHelper.convertDescDoc(${rtcParam.getDocActionOverView(7)})}
#end
   *
   * The error action in ERROR state
   *
   * @param ec_id target ExecutionContext Id
   *
   * @return RTC::ReturnCode_t
   * 
#if(${rtcParam.getDocActionPreCondition(7).length()}>0)   * @pre ${tmpltHelper.convertPreDoc(${rtcParam.getDocActionPreCondition(7)})}
#end
#if(${rtcParam.getDocActionPostCondition(7).length()}>0)   * @post ${tmpltHelper.convertPostDoc(${rtcParam.getDocActionPostCondition(7)})}
#end
   * 
   */
  #if(${rtcParam.IsNotImplemented(7)})//#end RTC::ReturnCode_t onError(RTC::UniqueId ec_id) override;

  /***
#if(${rtcParam.getDocActionOverView(8).length()}>0)   * ${tmpltHelper.convertDescDoc(${rtcParam.getDocActionOverView(8)})}
#end
   *
   * The reset action that is invoked resetting
   *
   * @param ec_id target ExecutionContext Id
   *
   * @return RTC::ReturnCode_t
   * 
#if(${rtcParam.getDocActionPreCondition(8).length()}>0)   * @pre ${tmpltHelper.convertPreDoc(${rtcParam.getDocActionPreCondition(8)})}
#end
#if(${rtcParam.getDocActionPostCondition(8).length()}>0)   * @post ${tmpltHelper.convertPostDoc(${rtcParam.getDocActionPostCondition(8)})}
#end
   * 
   */
  #if(${rtcParam.IsNotImplemented(8)})//#end RTC::ReturnCode_t onReset(RTC::UniqueId ec_id) override;
  
  /***
#if(${rtcParam.getDocActionOverView(10).length()}>0)   * ${tmpltHelper.convertDescDoc(${rtcParam.getDocActionOverView(10)})}
#end
   *
   * The state update action that is invoked after onExecute() action
   *
   * @param ec_id target ExecutionContext Id
   *
   * @return RTC::ReturnCode_t
   * 
#if(${rtcParam.getDocActionPreCondition(10).length()}>0)   * @pre ${tmpltHelper.convertPreDoc(${rtcParam.getDocActionPreCondition(10)})}
#end
#if(${rtcParam.getDocActionPostCondition(10).length()}>0)   * @post ${tmpltHelper.convertPostDoc(${rtcParam.getDocActionPostCondition(10)})}
#end
   * 
   */
  #if(${rtcParam.IsNotImplemented(10)})//#end RTC::ReturnCode_t onStateUpdate(RTC::UniqueId ec_id) override;

  /***
#if(${rtcParam.getDocActionOverView(11).length()}>0)   * ${tmpltHelper.convertDescDoc(${rtcParam.getDocActionOverView(11)})}
#end
   *
   * The action that is invoked when execution context's rate is changed
   *
   * @param ec_id target ExecutionContext Id
   *
   * @return RTC::ReturnCode_t
   * 
#if(${rtcParam.getDocActionPreCondition(11).length()}>0)   * @pre ${tmpltHelper.convertPreDoc(${rtcParam.getDocActionPreCondition(11)})}
#end
#if(${rtcParam.getDocActionPostCondition(11).length()}>0)   * @post ${tmpltHelper.convertPostDoc(${rtcParam.getDocActionPostCondition(11)})}
#end
   * 
   */
  #if(${rtcParam.IsNotImplemented(11)})//#end RTC::ReturnCode_t onRateChanged(RTC::UniqueId ec_id) override;
  // </rtc-template>


 protected:
  // <rtc-template block="protected_attribute">
#foreach($protectedAttribute in ${rtcParam.protectedAttributes})
  ${protectedAttribute}
#end
  
  // </rtc-template>

  // <rtc-template block="protected_operation">
#foreach($protectedOperation in ${rtcParam.protectedOperations})
  ${protectedOperation}
#end
  
  // </rtc-template>

  // Configuration variable declaration
  // <rtc-template block="config_declare">
#if( ${rtcParam.configParams.size()} > 0 )
#foreach($configParam in ${rtcParam.configParams})
  /*!
   * ${tmpltHelper.convertDescDoc(${configParam.docDescription})}
   * - Name: ${configParam.docDataName} ${configParam.tmplVarName}
   * - DefaultValue: ${configParam.defaultVal}
#if(${configParam.docUnit.length()}>0)   * - Unit: ${tmpltHelper.convertUnitDoc(${configParam.docUnit})}
#end
#if(${configParam.docRange.length()}>0)   * - Range: ${tmpltHelper.convertRangeDoc(${configParam.docRange})}
#end
#if(${configParam.docConstraint.length()}>0)   * - Constraint: ${tmpltHelper.convertConstraintDoc(${configParam.docConstraint})}
#end
   */
  ${cXXConv.convConfigSetType(${configParam.type})} ${rtcParam.commonPrefix}${rtcParam.configurationPrefix}${configParam.tmplVarName}${rtcParam.configurationSuffix}${rtcParam.commonSuffix};
#end
#end

  // </rtc-template>

  // DataInPort declaration
  // <rtc-template block="inport_declare">
#foreach($port in ${rtcParam.inports})
#if(${port.type}!="")  ${port.type} ${rtcParam.commonPrefix}${rtcParam.dataPortPrefix}${port.tmplVarName}${rtcParam.dataPortSuffix}${rtcParam.commonSuffix};
  /*!
#if(${port.docDescription.length()}>0)   * ${tmpltHelper.convertDescDoc(${port.docDescription})}
#end
#if(${port.docType.length()}>0)   * - Type: ${tmpltHelper.convertTypeDoc(${port.docType})}
#end
#if(${port.docNum.length()}>0)   * - Number: ${tmpltHelper.convertNumberDoc(${port.docNum})}
#end
#if(${port.docSemantics.length()}>0)   * - Semantics: ${tmpltHelper.convertSemanticsDoc(${port.docSemantics})}
#end
#if(${port.docUnit.length()}>0)   * - Unit: ${tmpltHelper.convertUnitDoc(${port.docUnit})}
#end
#if(${port.docOccurrence.length()}>0)   * - Frequency: ${tmpltHelper.convertFrequencyDoc(${port.docOccurrence})}
#end
#if(${port.docOperation.length()}>0)   * - Operation Cycle: ${tmpltHelper.convertCycleDoc(${port.docOperation})}
#end
   */
  RTC::InPort<${port.type}> ${rtcParam.commonPrefix}${rtcParam.dataPortPrefix}${port.tmplVarName}In${rtcParam.dataPortSuffix}${rtcParam.commonSuffix};
#end
#end
  
  // </rtc-template>


  // DataOutPort declaration
  // <rtc-template block="outport_declare">
#foreach($port in ${rtcParam.outports})
#if(${port.type}!="")  ${port.type} ${rtcParam.commonPrefix}${rtcParam.dataPortPrefix}${port.tmplVarName}${rtcParam.dataPortSuffix}${rtcParam.commonSuffix};
  /*!
#if(${port.docDescription.length()}>0)   * ${tmpltHelper.convertDescDoc(${port.docDescription})}
#end
#if(${port.docType.length()}>0)   * - Type: ${tmpltHelper.convertTypeDoc(${port.docType})}
#end
#if(${port.docNum.length()}>0)   * - Number: ${tmpltHelper.convertNumberDoc(${port.docNum})}
#end
#if(${port.docSemantics.length()}>0)   * - Semantics: ${tmpltHelper.convertSemanticsDoc(${port.docSemantics})}
#end
#if(${port.docUnit.length()}>0)   * - Unit: ${tmpltHelper.convertUnitDoc(${port.docUnit})}
#end
#if(${port.docOccurrence.length()}>0)   * - Frequency: ${tmpltHelper.convertFrequencyDoc(${port.docOccurrence})}
#end
#if(${port.docOperation.length()}>0)   * - Operation Cycle: ${tmpltHelper.convertCycleDoc(${port.docOperation})}
#end
   */
  RTC::OutPort<${port.type}> ${rtcParam.commonPrefix}${rtcParam.dataPortPrefix}${port.tmplVarName}Out${rtcParam.dataPortSuffix}${rtcParam.commonSuffix};
#end
#end
  
  // </rtc-template>

  // CORBA Port declaration
  // <rtc-template block="corbaport_declare">
#if(${rtcParam.servicePorts.size()}>0)
#foreach($servicePort in ${rtcParam.servicePorts})
#if(${servicePort.servicePortInterfaces.size()}>0)
  /*!
#if(${servicePort.docDescription.length()}>0)   * ${tmpltHelper.convertDescDoc(${servicePort.docDescription})}
#end
#if(${servicePort.docIfDescription.length()}>0)   * Interface: ${tmpltHelper.convertInterfaceDoc(${servicePort.docIfDescription})}
#end
   */
  RTC::CorbaPort ${rtcParam.commonPrefix}${rtcParam.servicePortPrefix}${servicePort.name}Port${rtcParam.servicePortSuffix}${rtcParam.commonSuffix};
#end#end#end
  
  // </rtc-template>

  // Service declaration
  // <rtc-template block="service_declare">
#if(${rtcParam.servicePorts.size()}>0)
#foreach($servicePort in ${rtcParam.servicePorts})
#if(${servicePort.servicePortInterfaces.size()}>0)
#foreach($serviceInterface in ${servicePort.servicePortInterfaces})
#if(${serviceInterface.index}==0)
  /*!
#if(${serviceInterface.docDescription.length()}>0)   * ${tmpltHelper.convertDescDoc(${serviceInterface.docDescription})}
#end
#if(${serviceInterface.docArgument.length()}>0)   * - Argument:      ${tmpltHelper.convertInterfaceDetailDoc(${serviceInterface.docArgument})}
#end
#if(${serviceInterface.docReturn.length()}>0)   * - Return Value:  ${tmpltHelper.convertInterfaceDetailDoc(${serviceInterface.docReturn})}
#end
#if(${serviceInterface.docException.length()}>0)   * - Exception:     ${tmpltHelper.convertInterfaceDetailDoc(${serviceInterface.docException})}
#end
#if(${serviceInterface.docPreCondition.length()}>0)   * - PreCondition:  ${tmpltHelper.convertInterfaceDetailDoc(${serviceInterface.docPreCondition})}
#end
#if(${serviceInterface.docPostCondition.length()}>0)   * - PostCondition: ${tmpltHelper.convertInterfaceDetailDoc(${serviceInterface.docPostCondition})}
#end
   */
  ${tmpltHelper.getBasename2(${serviceInterface.interfaceType})}${tmpltHelper.serviceImplSuffix} ${rtcParam.commonPrefix}${rtcParam.serviceIFPrefix}${serviceInterface.tmplVarName}${rtcParam.serviceIFSuffix}${rtcParam.commonSuffix};
#end#end#end#end#end
  
  // </rtc-template>

  // Consumer declaration
  // <rtc-template block="consumer_declare">
#if(${rtcParam.servicePorts.size()}>0)
#foreach($servicePort in ${rtcParam.servicePorts})
#if(${servicePort.servicePortInterfaces.size()}>0)
#foreach($serviceInterface in ${servicePort.servicePortInterfaces})
#if(${serviceInterface.index}==1)
  /*!
#if(${serviceInterface.docDescription.length()}>0)   * ${tmpltHelper.convertDescDoc(${serviceInterface.docDescription})}
#end
#if(${serviceInterface.docArgument.length()}>0)   * - Argument:      ${tmpltHelper.convertInterfaceDetailDoc(${serviceInterface.docArgument})}
#end
#if(${serviceInterface.docReturn.length()}>0)   * - Return Value:  ${tmpltHelper.convertInterfaceDetailDoc(${serviceInterface.docReturn})}
#end
#if(${serviceInterface.docException.length()}>0)   * - Exception:     ${tmpltHelper.convertInterfaceDetailDoc(${serviceInterface.docException})}
#end
#if(${serviceInterface.docPreCondition.length()}>0)   * - PreCondition:  ${tmpltHelper.convertInterfaceDetailDoc(${serviceInterface.docPreCondition})}
#end
#if(${serviceInterface.docPostCondition.length()}>0)   * - PostCondition: ${tmpltHelper.convertInterfaceDetailDoc(${serviceInterface.docPostCondition})}
#end
   */
  RTC::CorbaConsumer<${serviceInterface.interfaceType}> ${rtcParam.commonPrefix}${rtcParam.serviceIFPrefix}${serviceInterface.tmplVarName}${rtcParam.serviceIFSuffix}${rtcParam.commonSuffix};
#end#end#end#end#end
  
  // </rtc-template>

#if( ${tmpltHelper.checkFSM(${rtcParam})} )
  // State machine declaration
  // <rtc-template block="fsm_declare">
  RTC::Machine<${rtcParam.name}Fsm::${tmpltHelper.getTopFSMName(${rtcParam})}> m_fsm;
  // </rtc-template>
  
  // EventPort declaration
  // <rtc-template block="event_declare">
  
  RTC::EventInPort< RTC::Machine<${rtcParam.name}Fsm::${tmpltHelper.getTopFSMName(${rtcParam})}> > ${rtcParam.commonPrefix}${rtcParam.dataPortPrefix}${rtcParam.getEventport().tmplVarName}In${rtcParam.dataPortSuffix}${rtcParam.commonSuffix};
  // </rtc-template>
#end

 private:
  // <rtc-template block="private_attribute">
#foreach($privateAttribute in ${rtcParam.privateAttributes})
  ${privateAttribute}
#end
  
  // </rtc-template>

  // <rtc-template block="private_operation">
#foreach($privateOperation in ${rtcParam.privateOperations})
  ${privateOperation}
#end
  
  // </rtc-template>

};


extern "C"
{
  DLL_EXPORT void ${rtcParam.name}Init(RTC::Manager* manager);
};

#endif // ${rtcParam.name.toUpperCase()}_H
